package com.atguigu.spzx.manager.service.impl;

import com.atguigu.spzx.manager.mapper.ProductSpecMapper;
import com.atguigu.spzx.manager.service.ProductSpecService;
import com.atguigu.spzx.model.entity.product.ProductSpec;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LT
 * @create 2024-03-18-18:08
 */
@Service
public class ProductSpecServiceImpl implements ProductSpecService {

    @Resource
    ProductSpecMapper productSpecMapper;

    @Override
    public PageInfo<ProductSpec> GetProductSpecs(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<ProductSpec> productSpecs = productSpecMapper.GetProductSpecs();
        return new PageInfo<>(productSpecs);
    }

    @Override
    public List<ProductSpec> GetAllProductSpec() {
        List<ProductSpec> productSpecs = productSpecMapper.GetProductSpecs();
        return productSpecs;
    }

    @Override
    public ProductSpec GetProductSpecById(Long id) {
        ProductSpec productSpec = productSpecMapper.GetProductSpecById(id);
        return productSpec;
    }

    @Override
    public void UpdateProductSpec(ProductSpec productSpec) {
        productSpecMapper.UpdateProductSpec(productSpec);
    }

    @Override
    public void DeleteProductSpec(Long id) {
        productSpecMapper.DeleteProductSpec(id);
    }

    @Override
    public void SaveProductSpec(ProductSpec productSpec) {
        productSpecMapper.SaveProductSpec(productSpec);
    }
}
